﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WordWonderGame.UI;
using System.Media;
using WordWonderGame.Business;

namespace WordWonderGame
{
    public partial class FormKhoiDong : Form
    {
        DiemSoCaoUI frmDiemSoCao;
        GioiThieuUI frmGioiThieu;
        LoadingUI frmLoading;
        public event EventHandler BatDauChoi;

        public FormKhoiDong()
        {
            InitializeComponent();
            //frmDiemSoCao
            frmDiemSoCao = new DiemSoCaoUI();
            frmDiemSoCao.Dock = DockStyle.Fill;
            frmDiemSoCao.Parent = pnMain;
            frmDiemSoCao.Visible = false;
            //frmGioiThieu
            frmGioiThieu = new GioiThieuUI();
            frmGioiThieu.Dock = DockStyle.Fill;
            frmGioiThieu.Parent = pnMain;
            frmGioiThieu.Visible = false;
            //frmLoading
        }

        private void btGioiThieu_Click(object sender, EventArgs e)
        {
            SoundPlayer playerbutton = new SoundPlayer(@"Sound\button_click.wav");
            playerbutton.Play();
            pnHinhTiengViet.Visible = false;
            btGioiThieu.Visible = false;
            btDiemCao.Visible = false;
            btBatDau.Visible = false;
            btBack.Visible = true;
            frmDiemSoCao.Visible = false;
            frmGioiThieu.Visible = true;
        }

        private void FormKhoiDong_Load(object sender, EventArgs e)
        {
            frmGioiThieu.Visible = false;
        }

        private void btDiemCao_Click(object sender, EventArgs e)
        {
            SoundPlayer playerbutton = new SoundPlayer(@"Sound\button_click.wav");
            playerbutton.Play();
            btGioiThieu.Visible = false;
            btDiemCao.Visible = false;
            btBatDau.Visible = false;
            btBack.Visible = true;
            
            pnHinhTiengViet.Visible = false;
            DataClassDAL dataClass = new DataClassDAL();
            DataTable bangDiem = dataClass.LayDiemSoCao();
            frmDiemSoCao.BangDiem = bangDiem;
            frmDiemSoCao.Visible = true;
            frmGioiThieu.Visible = false;
        }

        private void btBatDau_Click(object sender, EventArgs e)
        {
            SoundPlayer playerbutton = new SoundPlayer(@"Sound\button_click.wav");
            playerbutton.Play();
            frmLoading = new LoadingUI();
            frmLoading.LoadSuccess += new EventHandler(frmLoading_LoadSuccess);
            frmLoading.ShowDialog();
        }

        void frmLoading_LoadSuccess(object sender, EventArgs e)
        {
            if (BatDauChoi != null)
            {
                BatDauChoi(this, null);
            }
        }

        private void btBack_Click(object sender, EventArgs e)
        {
            SoundPlayer playerbutton = new SoundPlayer(@"Sound\button_click.wav");
            playerbutton.Play();
            btBack.Visible = false;
            btBatDau.Visible = true;
            btDiemCao.Visible = true;
            btGioiThieu.Visible = true;
            pnHinhTiengViet.Visible = true;
            frmDiemSoCao.Visible = false;
            frmGioiThieu.Visible = false;
        }
    }
}
